#include <SDL/SDL.h>
#include <SDL/SDL_Image.h>
#include "constantes.h"
#include "fichiers.h"
#include "jeu.h"

SDL_Surface* screen;

int main(int argc, char* argv[])
{
    SDL_Surface* menu;
    SDL_Event input;

    SDL_Init(SDL_INIT_VIDEO);
    screen = SDL_SetVideoMode(LARGEUR_FENETRE, HAUTEUR_FENETRE, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
    SDL_WM_SetCaption("TP Mario Sokoban", NULL);
    SDL_EnableKeyRepeat(100, 100);

    menu = IMG_Load("images/menu.PNG");
    while (SDL_WaitEvent(&input))
    {
        switch (input.type)
        {
            case SDL_QUIT:
                quit();
            case SDL_KEYDOWN:
                switch (input.key.keysym.sym)
                {
                    case SDLK_1:
                    case SDLK_KP1:
                        loadGame();
                        break;
                    case SDLK_2:
                    case SDLK_KP2:
                        //editor();
                        break;
                    default: ;
                }
                break;
        }
        SDL_BlitSurface(menu, NULL, screen, NULL);
        SDL_Flip(screen);
    }

    printf("error while acquiring event in function main line %d in %s", __LINE__, __FILE__);
    SDL_FreeSurface(menu);
    SDL_Quit();
    return EXIT_FAILURE;
}
